load("@fbsource//tools/build_defs:rust_binary.bzl", "rust_binary")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")
load("@fbsource//tools/build_defs:rust_unittest.bzl", "rust_unittest")

oncall("source_control")

rust_library(
    name = "test_utils",
    srcs = glob(["test_utils/src/*.rs"]),
    autocargo = {"cargo_toml_dir": "test_utils"},
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:maplit",
        "//common/rust/shed/fbinit:fbinit",
        "//eden/mononoke/mononoke_api:mononoke_api",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_factory:test_repo_factory",
        "//eden/mononoke/tests/utils:tests_utils",
    ],
)

rust_unittest(
    name = "tests",
    srcs = glob(["tests/gitexport_tools/**/*.rs"]),
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:tracing",
        ":gitexport_tools",
        ":test_utils",
        "//common/rust/shed/borrowed:borrowed",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/mononoke_api:mononoke_api",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types",
    ],
)

rust_library(
    name = "gitexport_tools",
    srcs = glob(["src/gitexport_tools/*.rs"]),
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:indicatif",
        "fbsource//third-party/rust:itertools",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tracing",
        "//common/rust/shed/borrowed:borrowed",
        "//common/rust/shed/cloned:cloned",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/futures_stats:futures_stats",
        "//common/rust/shed/sql:sql",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/blobstore:fileblob",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "//eden/mononoke/derived_data:changeset_info",
        "//eden/mononoke/derived_data:derived_data_manager",
        "//eden/mononoke/derived_data:unodes",
        "//eden/mononoke/features/commit_transformation:commit_transformation",
        "//eden/mononoke/git/git_types:git_types",
        "//eden/mononoke/git/packfile:packfile",
        "//eden/mononoke/git/protocol:protocol",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_api:mononoke_api",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bookmarks/warm_bookmarks_cache:warm_bookmarks_cache",
        "//eden/mononoke/repo_attributes/git_symbolic_refs:git_symbolic_refs",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_factory:test_repo_factory",
    ],
)

# Binary to export a subset of a mononoke repository to a git repo.
rust_binary(
    name = "gitexport",
    srcs = [
        "src/main.rs",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_json",
        "fbsource//third-party/rust:tracing",
        ":gitexport_tools",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/futures_stats:futures_stats",
        "//eden/mononoke/cmdlib/commit_id:commit_id",
        "//eden/mononoke/cmdlib/displaying/graph:print_graph",
        "//eden/mononoke/cmdlib/mononoke_app:mononoke_app",
        "//eden/mononoke/common/scuba_ext:scuba_ext",
        "//eden/mononoke/derived_data:derived_data_remote",
        "//eden/mononoke/mononoke_api:mononoke_api",
        "//eden/mononoke/mononoke_repos:mononoke_repos",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bookmarks/bookmarks_types:bookmarks_types",
        "//eden/mononoke/repo_authorization:repo_authorization",
        "//eden/mononoke/repo_factory:repo_factory",
    ],
)
